fix(hook): resolve message extraction conflict between memory and RAG…#1435
Open
hexly666 wants to merge 3 commits into
Open
fix(hook): resolve message extraction conflict between memory and RAG…#1435hexly666 wants to merge 3 commits into
hexly666 wants to merge 3 commits into
Conversation
… hooks When both StaticLongTermMemoryHook and GenericRAGHook are attached to the same agent, they interfered with each other's message extraction logic. Each hook searches for "the last user message" to use as its query, but since both hooks inject their results as USER role messages at the end of the message list, one hook could pick up the other hook's injected message instead of the original user input. Changes: - GenericRAGHook: Change injected message name from "user" to "retrieved_knowledge" for clear identification; skip messages with name "long_term_memory" when extracting user query - StaticLongTermMemoryHook: Skip messages with name "retrieved_knowledge" when extracting user query - Add tests to verify hook interference is resolved Closes agentscope-ai#1403
|
helm30 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
added 2 commits
May 19, 2026 10:03
… logic Use scoreThreshold=0.0 to guarantee RAG retrieval triggers in the hook-interference test, ensuring the name-based skip branch is actually executed. Add edge-case test for when all USER messages are hook-injected (no genuine user query available).
…ogic Add unit tests in agentscope-core using a mocked Knowledge interface to cover the long_term_memory skip branch in GenericRAGHook#extractQueryFromMessages. This addresses the 6 missing lines reported by Codecov (Patch 0.00%) since agentscope-core coverage does not include tests from agentscope-extensions modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… hooks
When both StaticLongTermMemoryHook and GenericRAGHook are attached to the same agent, they interfered with each other's message extraction logic. Each hook searches for "the last user message" to use as its query, but since both hooks inject their results as USER role messages at the end of the message list, one hook could pick up the other hook's injected message instead of the original user input.
Changes:
Closes #1403
AgentScope-Java Version
[The version of AgentScope-Java you are working on, e.g. 1.0.12, check your pom.xml dependency version or run
mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]Description
[Please describe the background, purpose, changes made, and how to test this PR]
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)